package com.adingxiong.cft.kafka;

import org.apache.kafka.clients.producer.ProducerConfig;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

/**
 * @ClassName KafkaConfig
 * @Description TODO
 * @Author xiongchao
 * @Date 2021/3/19 15:25
 **/
public class KafkaConfig {


    /**
     * 初始化kafka的相关配置
     * @return
     */
    public static Properties initConfig(){
        Properties prop = new Properties();

        prop.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG,"192.168.10.101:9092");
        //确认机制
        prop.put(ProducerConfig.ACKS_CONFIG,"all");
        //重试次数
        prop.put(ProducerConfig.RETRIES_CONFIG,1);
        //批次大小
        prop.put(ProducerConfig.BATCH_SIZE_CONFIG,16384);
        //等待时间
        prop.put(ProducerConfig.LINGER_MS_CONFIG,1);
        //缓冲区大小
        prop.put(ProducerConfig.BUFFER_MEMORY_CONFIG,33356444);
        prop.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
        prop.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
        return  prop;
    }

    public static void main(String[] args) {
        String str = "我 是 张三";
        List<String> list = Arrays.asList(str.split(" "));
        StringBuilder builder = new StringBuilder();
        Collections.reverse(list);
        list.forEach(e -> {
            builder.append(e);
        });


    }
}
